<template>
    <div>
<el-card shadow="always" :body-style="{ padding: '20px' }">
 <el-form  ref="form" label-width="80px" :inline="true" >
    <el-form-item label="一级分类" >
        <el-select v-model="categoryStore.c1id" :disabled="scene!=0"   placeholder="请选择" size="large" @change="c1Hanler">
            <el-option
              v-for="(c1,index) in categoryStore.c1List"
              :key="c1.id"
              :label="c1.name"
              :value="c1.id"
            />
          </el-select>
    </el-form-item>
    <el-form-item label="二级分类">
        <el-select v-model="categoryStore.c2id" :disabled="scene!=0"  placeholder="请选择" size="large"  @change="c2Hanler">
            <el-option
            v-for="(c2,index) in categoryStore.c2List"
            :key="c2.id"
            :label="c2.name"
            :value="c2.id"
            />
          </el-select>
    </el-form-item>
    <el-form-item label="三级分类">
        <el-select v-model="categoryStore.c3id" :disabled="scene!=0"   placeholder="请选择" size="large">
            <el-option
            v-for="(c3,index) in categoryStore.c3List"
            :key="c3.id"
            :label="c3.name"
            :value="c3.id"
            />
          </el-select>
    </el-form-item>
 </el-form>
 
</el-card>

    </div>
</template>

<script setup lang="ts">
import { ref,onMounted } from 'vue';
// 引入仓库
import {useCategoryStore} from '@/stores/category'
// 调用仓库
let categoryStore = useCategoryStore()

// 挂载完毕通知pinia仓库发请求,获取一级分类数据
onMounted(() => {
    categoryStore.getC1List()
})

// 一级分类下拉才对呢的change事件回调,获取二级分类菜单数据
const c1Hanler = ()=>{
    categoryStore.getC2List()
}

// 二级分类下拉才对呢的change事件回调,获取三级分类菜单数据
const c2Hanler = ()=>{
    categoryStore.getC3List()
}

// 接收props参数
defineProps(['scene'])
</script>

<style scoped>

</style>